from app import db
class User(db.Model):
    __tablename__ = 'user'

    USER_ID = db.Column(db.Integer, primary_key=True)
    USERNAME = db.Column(db.String(20))
    CREATED_BY = db.Column(db.String(20))
    CREATED_DATE = db.Column(db.Date)

    def __init__(self,payload):
        self.USERNAME = payload['USERNAME']
        self.CREATED_BY = payload['CREATED_BY']
        self.CREATED_DATE = payload['CREATED_DATE']

    def save(self):
        db.session.add(self)
        db.session.commit()

    def to_json(self):
        dict = self.__dict__
        if "_sa_instance_state" in dict:
            del dict["_sa_instance_state"]
        return dict